package main

import (
	"sort"
)

var MOD int = 1e9 + 7
var MAXN int = 100_000
var POW2 []int = make([]int, MAXN)

func init() {
	POW2[0] = 1
	for i := 1; i < MAXN; i++ {
		POW2[i] = POW2[i - 1] * 2 % MOD
	}
}

func numSubseq(nums []int, target int) int {
    n := len(nums)
	sort.Ints(nums)
	l, r := 0, n - 1
	ans := 0
	for l <= r {
		if nums[l] + nums[r] > target {
			r--
		} else {
			ans = (ans + POW2[r - l]) % MOD
			l++
		}
	}
	return ans
}